From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue Mar 14 23:21:48 2006 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Tue Mar 14 23:21:48 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj@www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Tue Mar 14 23:21:48 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Tue Mar 14 23:21:48 2006 Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj@www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Tue Mar 14 23:21:48 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj@www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Tue Mar 14 23:21:48 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Tue Mar 14 23:21:48 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj@www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue Mar 28 18:25:08 2006 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Tue Mar 28 18:25:08 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj@www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Tue Mar 28 18:25:08 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Tue Mar 28 18:25:08 2006 Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj@www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Tue Mar 28 18:25:08 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj@www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Tue Mar 28 18:25:08 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Tue Mar 28 18:25:08 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj@www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue Mar 28 20:17:08 2006 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Tue Mar 28 20:17:08 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj@www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Tue Mar 28 20:17:08 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Tue Mar 28 20:17:08 2006 Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj@www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Tue Mar 28 20:17:08 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj@www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Tue Mar 28 20:17:08 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Tue Mar 28 20:17:08 2006 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj@www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401071556.28678.ari.suutari@syncrontech.com> Message-ID: > FreeBSD port system support many different JVM versions. > if you could just use JAVA_HOME environment variable to > find out the default directory everything should be fine. > > Eventually, it would be nice to get rxtx package into FreeBSD > ports collection, after that it would be very easy to install > it. I once wrote necessary stuff for bsd-licensed commapi > implementation (available at www.syncrontech.org), I guess > it would be easy to write something similar for rxtx. > Hi Ari, I'll follow up off list with the sample code suggestion. I'll also put a link to your project at www.syncrontech.org on rxtx.org if you dont mind (nice css btw). -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 23:39:18 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Thu, 8 Jan 2004 08:39:18 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401080839.18034.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > you dont mind (nice css btw). No problem. To clarify, I must say that the software has not been written by me, I have just been maintaining it since the original authors didn't have time/interest for it any more. (and I had projects using that stuff) Ari S. From taj at www.linux.org.uk Fri Jan 9 07:40:51 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Fri, 9 Jan 2004 14:40:51 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200401080839.18034.ari.suutari@syncrontech.com> Message-ID: On Thu, 8 Jan 2004, Ari Suutari wrote: > Hi, > > On Wednesday 07 January 2004 16:22, Trent Jarvi wrote: > > I'll also put a link to your project at www.syncrontech.org on rxtx.org if > > you dont mind (nice css btw). > > No problem. To clarify, I must say that the software has > not been written by me, I have just been maintaining it since > the original authors didn't have time/interest for it any more. > (and I had projects using that stuff) > Hi Ari I was able to reproduce the bug with your sample code on w32 and linux also. This is great news. I started hacking on the fix. I guess I missed the memo on JNI 1.1->1.2 (and 1.4). When that is done Saturday, I'll finish the FreeBSD compile fixes too. I'm placing the link to the project you now maintain on the links page. -- Trent Jarvi taj at www.linux.org.uk From tllynch at comcast.net Tue Jan 6 13:18:51 2004 From: tllynch at comcast.net (Tom Lynch) Date: Tue, 06 Jan 2004 15:18:51 -0500 Subject: [Rxtx] Another person trying to read from the lp0 Message-ID: <1073420330.1109.50.camel@localhost.localdomain> I have a printer that can report its status through the parallel port. If only I were able to read it! I can write to the printer using RXTX fine. I use this code to open an output stream: try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parportOut.getOutputStream(); ps = new PrintStream(outputStream); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to printer"); ioe.printStackTrace(); } And I can print to my heart's content. I use similiar code to open an input stream. However, this throws a null pointer exception at 'inputStream = parport.getInputStream();' try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { // this throws NullPointerException inputStream = parportIn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } } catch(Exception ioe){ javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from printer"); ioe.printStackTrace(); } Any suggestions? My boss really wants to be able to monitor the state of the printer. Thank you very much -tl -- From taj at www.linux.org.uk Wed Jan 7 06:08:26 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:08:26 +0000 (GMT) Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: <200312171700.23241.ari.suutari@syncrontech.com> Message-ID: On Wed, 17 Dec 2003, Ari Suutari wrote: > Hi, > > I'm new to rxtx (but not new to java commapi programming). > > I have been trying to use rxtx with FreeBSD jdk 1.4.2 (and 1.4.1) to > talk to dallas 1-wire devices. Mostly things work ok, > except that there are random crashes (which do not occur > when using sun's commapi). > > When running the test program with -Dcheck:jni following > messages are displayed: > > > %/usr/local/bsd-jdk1.4.1/bin/java -Xcheck:jni AirProto /dev/cuaa0 > Devel Library > ========================================= > Native lib Version = RXTX-2.1-7pre16 > Java lib Version = RXTX-2.1-7pre16 > RXTX Warning: Removing stale lock file. /var/spool/uucp/LK.255.028.128 > Trying to open /dev/cuaa0 > FATAL ERROR in native method: Using JNIEnv in the wrong thread > at gnu.io.RXTXPort.nativeDrain(Native Method) > at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1191) > at > com.dalsemi.onewire.adapter.SerialService.flush(SerialService.java:425) > - locked <0x2c2102d0> (a com.dalsemi.onewire.adapter.SerialService) > at com.dalsemi.onewire.adapter.USerialAdapter.uMasterReset(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.uAdapterPresent(Unknown > Source) > at com.dalsemi.onewire.adapter.USerialAdapter.adapterDetected(Unknown > Source) > at > com.dalsemi.onewire.OneWireAccessProvider.getAdapter(OneWireAccessProvider.java:377) > at AirProto.open(AirProto.java:117) > at AirProto.main(AirProto.java:48) > > > Notice the "using JNIEnv in the wrong thread", which means that > JNIEnv pointer is being used by a thread which did not obtain it. > > The rxrx versions I have triead are rxtx-2.1-7pre16 > and rxtx-2.1-6. Both seem to have same problem. > > Another minor thing under FreeBSD is that the lock directory > is not /var/spool/uucp, it is /var/spool/lock and the lock file > prefix is "LCK.." > Hi Ari I finally got around to looking at this some more. Right now I have more questions than answers with the important problem. I'm curious. Is this an SMP machine? Would you happen to be moving large files when this happens? With the jre and -Xcheck:jni, do you know of any jre's available without agreeing to the Sun Community Source License that are capable of identifying the JNIEnv thread variable problem? This was not showing up in the FreeBSD 1.3.1-0 jre. It looks like there may be binary compatability on freebsd allowing you to run most anything :) I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in Linux but it must only happen with the devel versions of the jre which are offered as patches against Sun's code at this point? With rxtx:2.1... I also see there are some build problems. I fixed all but two at this point. libtool is not linking to the pthread library and fuser.c was not being compiled. I'll have to look further into the libtool issue; its swallowing the options I give it. Here are the commands I used to compile a functional native lib. gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/SerialImp.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/SerialImp.o gcc -I/root/rxtx-2.1-7pre17/build -Ii386-unknown-freebsd4.9 -I. -I/java/include -I/java/include/./freebsd/ -g -O2 -D_BSD_SOURCE -D_NO_POSIX=1 -D_NO_XOPEN4=1 -c /root/rxtx-2.1-7pre17/build/../src/psmisc/fuser.c -fPIC -o /root/rxtx-2.1-7pre17/build/i386-unknown-freebsd4.9/.libs/fuser.o ld -share -lc_r i386-unknown-freebsd4.9/.libs/fuser.o i386-unknown-freebsd4.9/.libs/SerialImp.o -o i386-unknown-freebsd4.9/.libs/librxtxSerial.so cp i386-unknown-freebsd4.9/.libs/librxtxSerial.so /java/jre/lib/i386 Once I figure out what is wrong with libtool I'll fix that too. I also took the liberty to add a make -p .../java/jre/lib/ext to the Makefile to the jar can be added to the default classpath if make install is performed. If you have a known prefered location of freebsd, that could be changed. finally, the lock file problems are also resolved. -- Trent Jarvi taj at www.linux.org.uk From ari.suutari at syncrontech.com Wed Jan 7 06:56:28 2004 From: ari.suutari at syncrontech.com (Ari Suutari) Date: Wed, 7 Jan 2004 15:56:28 +0200 Subject: [Rxtx] FreeBSD and rxtx In-Reply-To: References: Message-ID: <200401071556.28678.ari.suutari@syncrontech.com> Hi, On Wednesday 07 January 2004 15:08, Trent Jarvi wrote: > Hi Ari > > I finally got around to looking at this some more. Right now I have more > questions than answers with the important problem. > > I'm curious. Is this an SMP machine? Would you happen to be moving large > files when this happens? This is a P4 machine with hyperthreading enabled. So, it is kind-of SMP. The machine was idle when the problem occurred. I can duplicate this also with RedHat linux 8.0 (kernel 2.4.18), ordinary P4, no hyperthreading or SMP at all. The JDK version is linux jdk 1.4.2_01, from Sun. > > With the jre and -Xcheck:jni, do you know of any jre's available without > agreeing to the Sun Community Source License that are capable of > identifying the JNIEnv thread variable problem? This was not showing up > in the FreeBSD 1.3.1-0 jre. It looks like there may be binary > compatability on freebsd allowing you to run most anything :) It might be so that 1.3 jdk doesn't check things so much, since on freebsd, 1.3.1 jdk doesn't use hotspot, it uses green threads. > > I installed FreeBSD 5.2 and 4.9 in vmware after not seeing the error in > Linux but it must only happen with the devel versions of the jre which are > offered as patches against Sun's code at this point? I think that you need to have 1.4 jdk for testing, maybe 1.4.2 if possible. Also, if you would like, I can send you off-list source code for a simple test program that crashes rxtx on freebsd and linux. Ari S. > > With rxtx:2.1... > > I also see there are some build problems. I fixed all but two at this > point. libtool is not linking to the pthread library and fuser.c was not > being compiled. Hmm, there is -lc_r, which *is* one of the pthread libraries available on freebsd. So no problem there, I think. -pthread option is no longer used in FreeBSD 5.2. > > I also took the liberty to add a make -p .../java/jre/lib/ext to the > Makefile to the jar can be added to the default classpath if make install > is performed. If you have a known prefered location of freebsd, that > could be changed. FreeBSD port system support many different JVM versions. if you could just use JAVA_HOME environment variable to find out the default directory everything should be fine. Eventually, it would be nice to get rxtx package into FreeBSD ports collection, after that it would be very easy to install it. I once wrote necessary stuff for bsd-licensed commapi implementation (available at www.syncrontech.org), I guess it would be easy to write something similar for rxtx. > finally, the lock file problems are also resolved. Great ! Ari S. From taj at www.linux.org.uk Wed Jan 7 06:58:41 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 13:58:41 +0000 (GMT) Subject: [Rxtx] Another person trying to read from the lp0 In-Reply-To: <1073420330.1109.50.camel@localhost.localdomain> Message-ID: On Tue, 6 Jan 2004, Tom Lynch wrote: > I have a printer that can report its status through the parallel port. > If only I were able to read it! > > I can write to the printer using RXTX fine. I use this code to open an > output stream: > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportOut = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > outputStream = parportOut.getOutputStream(); > ps = new PrintStream(outputStream); > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to write to > printer"); > ioe.printStackTrace(); > } > > And I can print to my heart's content. > > I use similiar code to open an input stream. However, this throws a > null pointer exception at 'inputStream = parport.getInputStream();' > > try{ > gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); > parportIn = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", > CommPortIdentifier.PORT_PARALLEL); > try { > // this throws NullPointerException > inputStream = parportIn.getInputStream(); > > } > catch (IOException e) { > e.printStackTrace(); > } > } > catch(Exception ioe){ > javax.swing.JOptionPane.showMessageDialog(null, "Unable to read from > printer"); > ioe.printStackTrace(); > } > > > Any suggestions? My boss really wants to be able to monitor the state > of the printer. > > Thank you very much > > -tl > > > > Most of the problems with reading involve w32 or trying to change printer modes in linux. The code is not mature but should be able to do simple things on linux. Perhaps with a little tweaking. This may not be the only problem you run into but its not a serious problem. You really don't want to open the port twice which happens underneath each time with: parPortDriver.getCommPort("/dev/lp0",CommPortIdentifier.PORT_PARALLEL); The following does not give the error mentioned and performs the same task: import gnu.io.*; import java.io.*; import java.util.*; public class PrintTest { public static void main( String[] args ) { ParallelPort parport; OutputStream outputStream; InputStream inputStream; PrintStream ps; try{ gnu.io.RXTXCommDriver parPortDriver = new RXTXCommDriver(); parport = (ParallelPort)parPortDriver.getCommPort("/dev/lp0", CommPortIdentifier.PORT_PARALLEL); try { outputStream = parport.getOutputStream(); ps = new PrintStream(outputStream); ps.print("ok"); // this throws NullPointerException inputStream = parport.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } catch(Exception e){ e.printStackTrace(); } } } Wed Jan 07 06:51:01 $ java print Devel Library ========================================= Native lib Version = RXTX-2.1-7pre17 Java lib Version = RXTX-2.1-7pre17 Wed Jan 07 06:51:23 $ java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Wed Jan 07 06:51:33 $ uname -a Linux servertrent.korpivaara.org 2.6.0-1.104 #1 Fri Dec 19 04:32:22 EST 2003 i686 i686 i386 GNU/Linux Wed Jan 07 06:51:36 $ -- Trent Jarvi taj at www.linux.org.uk From taj at www.linux.org.uk Wed Jan 7 07:22:06 2004 From: taj at www.linux.org.uk (Trent Jarvi) Date: Wed, 7 Jan 2004 14:22:06 +0000 (GMT) Subject: [Rxtx] FreeBSD